Skip to content

Delete misplaced GitHub rows without a same-number pair - #869

Merged
andrew merged 1 commit into
mainfrom
delete-unpaired-misplaced-rows
Nov 16, 2026
Merged

andrew merged 1 commit into
mainfrom
delete-unpaired-misplaced-rows

Conversation

@andrew

@andrew andrew commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #868 for #852. delete_misplaced_github_rows only considered rows that shared a number with another row in their repository, so foreign rows at numbers the repository hasn't reached yet stayed (opencollective-api still had #193655, #19872 and #13245 from other repositories). This drops the pairing condition and relies on the 80% majority rule alone.

Without the pair filter every repository with new-format node ids gets a lookup, so rows with legacy ids now skip the lookup and the home id cache is cleared past 100k entries to keep memory bounded.

Summary by CodeRabbit

  • Bug Fixes
    • Improved cleanup of misplaced GitHub issue records, including records without a matching issue elsewhere.
    • Legacy-format records are preserved when their repository ID cannot be determined, while records tied to the correct repository remain unaffected.

A foreign row at a number its repository hasn't reached yet has no pair, so the majority rule alone decides.
Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:53
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

delete_misplaced_github_rows now evaluates unpaired rows with non-null node IDs, skips rows with undecodable repository IDs, and deletes rows whose decoded repository ID differs from a known home ID. Tests cover these cases and verify that legacy-format rows remain.

Changes: Misplaced row cleanup

Layer / File(s) Summary
Candidate row evaluation
app/models/issue.rb, test/models/issue_test.rb
The cleanup method considers rows without requiring a matching issue number, skips rows with undecodable node IDs, and clears its repository-ID cache above 100,000 entries. Tests verify deletion of misplaced and unpaired rows, retention of tied and legacy-format rows, and no repository-ID lookup for a legacy-format-only repository.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • ecosyste-ms/issues#868: Adds the cleanup logic that this change modifies by removing its matching-issue requirement.
  • ecosyste-ms/issues#861: Reassigns issue rows during sync when they match on [host_id, uuid]; this change handles residual misplaced rows not moved by that sync.
Merge Risk: Minimal · up to 77ac5

The cleanup now also removes foreign GitHub rows that have no same-number pair, as intended. Legacy-format rows are preserved and the task's progress and count behavior is unchanged. No merge-blocking risk was found.

Security architecture risk: Minimal · up to 77ac5

The cleanup intentionally reaches more misplaced rows while preserving its ownership threshold, legacy-ID protection, and guard against deleting rows moved by concurrent synchronization. No introduced security or failure-containment defect was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — A task invocation can evaluate rows across repositories belonging to the selected GitHub host, not merely one repository. The PR expands eligible rows within that existing scope. Each delete is constrained by captured row IDs and repository_id; it does not independently recheck host_id or node_id.

Trust Boundaries and Controls

  • observed — The cleanup retains its sampled ownership threshold and preserves legacy IDs. The delete-time repository_id predicate also preserves a row moved to another repository after evaluation. Inspected tests cover unpaired deletion, legacy preservation, insufficient consensus, and concurrent repository movement; they do not prove every upstream ownership assumption.

Resilience and Maintainability Implications

  • observed — The ownership cache is local to one invocation and is cleared between batches when its size exceeds 100,000 entries. Clearing it causes later ownership estimates to be recomputed; it does not persist deletion decisions or alter reconciliation admission controls.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: misplaced GitHub rows are deleted without requiring a same-number pair. The raw summary confirms that delete_misplaced_github_rows no longer limits candidates to rows …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: misplaced GitHub rows are deleted without requiring a same-number pair. The raw summary confirms that delete_misplaced_github_rows no longer limits candidates to rows with a matching issue record, and the objectives say the same-number pairing condition is removed. The title is specific and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c24202fd-ac27-41dc-aa80-7a381083b2b3
Commits

Reviewing files that changed from the base of the PR and between f5dab8f and 77ac52e.

Files selected for processing: 2

  • app/models/issue.rb
  • test/models/issue_test.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the GitHub row-cleanup changes.

No open issues 🎉

What changed in this PR

Extends the GitHub row cleanup introduced in #868 to remove misplaced rows even when no same-number pair exists, addressing another part of #852.

Changes:

  • Removes the pairing requirement while retaining the 80% repository-majority rule.
  • Skips repository lookups for legacy node IDs and clears the cache above 100,000 entries.
  • Updates tests to cover unpaired-row deletion, legacy-row preservation, and skipped legacy lookups.
File Description
test/​models/​issue_test.rb Tests unpaired-row deletion and legacy node ID handling.
app/​models/​issue.rb Broadens cleanup eligibility and limits lookup and cache overhead.

Review effort: Balanced

@andrew
andrew merged commit 2952619 into main Nov 16, 2026
9 checks passed
@andrew
andrew deleted the delete-unpaired-misplaced-rows branch November 16, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants